package com.lyrcsoft.beanpostprocessors;

import com.lyrcsoft.service.T7Service;
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.stereotype.Component;

/**
 * 实例化之后，属性赋值之前的一个后置处理器（合并后的MergedBeanDefinition的PostProcessor）
 *
 * @author fujc-dev@qq.com
 * @date 2023/7/4 20:40
 */
@Component
public class UserServiceMergedBeanDefinitionPostProcessor implements MergedBeanDefinitionPostProcessor {

	@Override
	public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
		if (beanName.equals("t5Service")) {
			beanDefinition.setInitMethodName("a");
		}
		if (beanName.equals("t6Service")) {
			beanDefinition.getPropertyValues().add("t7Service", new T7Service());
		}
	}
}
